# import the necessary packages
import argparse
import cv2 as cv

# construct the argument parser and parse the arguments
ap = argparse.ArgumentParser()
ap.add_argument("-i", "--image", required=True, help="Path to the image")
args = vars(ap.parse_args())  # args是一个字典,字典的键就是image,value就是--image后面跟的文件路径字符串的值

# load the image and show some basic information on it
image = cv.imread(args["image"])
print("width: %d pixels" % (image.shape[1]))
print("height: %d pixels" % (image.shape[0]))
print("channels: %d" % (image.shape[2]))
print("image.shape: {}".format(image.shape))

# show the image and wait for a keypress
cv.imshow("Image", image)
cv.waitKey(0)

# save the image -- OpenCV handles converting filetypes
# automatically
cv.imwrite("newImage.jpg",image)
